#include "Resources.h"
#include <string>
#include <vector>
#include "ogg/ogg.h"
#include "vorbis/codec.h"
#include "vorbis/vorbisfile.h"
#include "Sound.h"
#include "SoundManager.h"

#pragma once

namespace UniverseSound
{
	class StaticSound : public SoundClip
	{
	public:
		void open(Ogre::DataStreamPtr& fileStream);
		void open(const Ogre::String& fileName, ALuint& buffer);
		void stop();
		void setSource(ALuint& source);
		void pause();
		void play();
		void loop(bool loop);

	protected:
		StaticSound(const Ogre::String& name);
		~StaticSound();

		void _updateAudioBuffers();
		void _prebuffer();
		bool _queryBufferInfo();

	private:
		void _release();

		FILE *mAudioFile;
		OggVorbis_File *mOggStream;
		vorbis_info *mVorbisInfo;
		vorbis_comment *mVorbisComment;

		Ogre::String mAudioName;

		std::vector<char> mBufferData;

		ALuint mBuffer;
		ALenum mFormat;
		ALint mCurrentPlayPosition;

		friend class SoundManager;
	};
}